package com.example.yuejian21.nongfusanquan.yuejian21.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.yuejian21.nongfusanquan.yuejian21.R;
import com.squareup.picasso.Picasso;

/**
 * Created by Nongfusanquan on 2017-10-24.
 */

public class CouchdetailActivity extends AppCompatActivity {
    private TextView couchdetail_name,couchdetail_info;
    private ImageView couchdetail_pic;
    private Button couchdetail_return,couchdetail_more;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_couchdetail);
        initViews();
        initEvent();
        getData();
    }

    private void initViews(){
        couchdetail_name = (TextView)findViewById(R.id.couchdetail_name);
        couchdetail_info = (TextView)findViewById(R.id.couchdetail_info);
        couchdetail_pic = (ImageView)findViewById(R.id.couchdetail_pic);
        couchdetail_return = (Button)findViewById(R.id.couchdetail_return);
        couchdetail_more = (Button)findViewById(R.id.couchdetail_more);
    }

    private  void initEvent(){
        couchdetail_return.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        couchdetail_more.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setClass(CouchdetailActivity.this,CouchcourseActivity.class);
                startActivityForResult(intent,1);

                }

            }
        );
    }

     private void getData(){
         Bundle bundle = this.getIntent().getExtras();
         String aname = bundle.getString("pm_name");
         String aintro =bundle.getString("pm_info");
//         String couchpic = bundle.getString("pm_pic");
         String t_picture = bundle.getString("pm_pic");
         couchdetail_name.setText(aname);
         couchdetail_info.setText(aintro);
         Picasso.with(this).load(t_picture).into(couchdetail_pic);

     }
     }
